var resourceProperty = require('../common/config.js');

var url = require('url');

var wsLocation = url.parse(resourceProperty.getUrl());

module.exports = {
  '/show/show/api/ws/dataset': function(pathname) {
    var target = wsLocation.protocol + '//' + wsLocation.host;
    var option = {
      target: target,
      headers: {
        referer: target,
        origin: target
      }
    }
    option.pathRewrite = pathname;
    return option;
  },
  '/show/api/ws/dataset': function(pathname) {
    var target = wsLocation.protocol + '//' + wsLocation.host;
    var option = {
      target: target,
      headers: {
        referer: target + wsLocation.pathname,
        origin: target
      }
    }
    if (wsLocation.pathname.length > 1) {
      option.pathRewrite = wsLocation.pathname + pathname;
    }
    return option;
  },
  '/api/ws/dataset': function(pathname) {
    var target = wsLocation.protocol + '//' + wsLocation.host;
    var option = {
      target: target,
      headers: {
        referer: target + wsLocation.pathname,
        origin: target
      }
    }
    //不带path时pathname为"/"
    if (wsLocation.pathname.length > 1) {
      option.pathRewrite = wsLocation.pathname + pathname;
    }
    return option;
  },
  '/chatops/api/v2/chat/snapper/socket/': function(pathname) {
    var target = wsLocation.protocol + '//' + wsLocation.host;
    var option = {
      target: target,
      headers: {
        referer: target,
        origin: target
      }
    }
    return option;
  }
}